<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0">
    <!--<link rel="shortcut icon" href="https://xlzy520.cn/icons/love.ico">-->
    <link rel="icon" type="image/png" href="https://xlzy520.cn/icons/love.png">
    <title>Title</title>
</head>
<body>
<script>
  function getBase64Image(img) {
    const canvas = document.createElement("canvas");
    canvas.width = img.width;
    canvas.height = img.height;
    const ctx = canvas.getContext("2d");
    ctx.drawImage(img, 0, 0, img.width, img.height);
    const ext = img.src.substring(img.src.lastIndexOf(".")+1).toLowerCase();
    const dataURL = canvas.toDataURL("image/"+ext);
    return dataURL;
  }
  const imgLink = "https://gss0.bdstatic.com/5bVWsj_p_tVS5dKfpU_Y_D3/res/r/image/2018-09-21/c92c6edb062cc35b1b51377ff6ab090b.png";
  const tempImage = new Image();
  tempImage.src = imgLink;
  tempImage.crossOrigin = "*";
  tempImage.onload = function(){
    var base64 = getBase64Image(tempImage);
    const base64Img = new Image()
    base64Img.src = base64
    document.querySelector('body').appendChild(base64Img)
  }

</script>
</body>
</html>
